/*
 * NcsLogger.cpp
 *
 *  Created on: Jun 24, 2017
 *      Author: zjf
 */

#include <Poco/AutoPtr.h>
#include <Poco/FileChannel.h>
#include <Poco/FormattingChannel.h>
#include <Poco/PatternFormatter.h>
#include <Poco/PatternFormatter.h>
#include <Poco/Logger.h>

using namespace Poco;

#include "NcsLogger.h"

namespace Logger
{

void initLogger(std::string& file)
{
    AutoPtr<FileChannel> file_channel(new FileChannel());
    file_channel->setProperty("rotation" ,"10M");
    file_channel->setProperty("archive" ,"timestamp");
    file_channel->setProperty("path" ,file);
    AutoPtr<PatternFormatter> pattern_formatter (new PatternFormatter("%L%H:%M:%S-code line :%u-%U : %t"));
    AutoPtr<FormattingChannel> formatter_channle(new FormattingChannel(pattern_formatter , file_channel));
    Poco::Logger::root().setChannel(formatter_channle);
}

}

